<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:variable name="ALPHA_LOWER">abcdefghijklmnopqrstuvwxyz</xsl:variable>
	<xsl:variable name="ALPHA_UPPER">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

	<xsl:template name="convertCase">
		<xsl:param name="pDirection" />
		<xsl:param name="pSource" />

		<xsl:choose>
			<xsl:when test='$pDirection="lower"'>
				<xsl:value-of
				select="translate( $pSource, $ALPHA_UPPER, $ALPHA_LOWER )" />
			</xsl:when>

			<xsl:when test='$pDirection="upper"'>
				<xsl:value-of
				select="translate( $pSource, $ALPHA_LOWER, $ALPHA_UPPER )" />
			</xsl:when>

			<xsl:when test="$pDirection='proper'">
				<xsl:call-template name="convertProperCase">
					<xsl:with-param name="pSource">
					<xsl:value-of select="translate( $pSource, $ALPHA_UPPER, $ALPHA_LOWER )" />
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$pSource" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="convertProperCase">
		<!-- Recursive Function to convert a string to Proper Case. -->
		<xsl:param name="pSource" />

		<xsl:if test="string-length( $pSource ) &gt; 0">
			<xsl:variable name="vFirstCharacter" select="substring( $pSource, 1, 1 )" />
			<xsl:variable name="vRemainingString" select="substring( $pSource, 2 )" />

			<xsl:call-template name="convertCase">
				<xsl:with-param name="pSource" select="$vFirstCharacter" />
				<xsl:with-param name="pDirection">upper</xsl:with-param>
			</xsl:call-template>

			<xsl:choose>
			<xsl:when test="contains( $vRemainingString,' ' )">
			<xsl:value-of select="substring-before( $vRemainingString,' ' )" />

	          
			<xsl:call-template name="convertProperCase">
				<xsl:with-param name="pSource" select="substring-after( $vRemainingString, ' ' )" />
			</xsl:call-template>
			</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$vRemainingString" />
			</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

   <xsl:template name="getXSLType">
      <xsl:param name="pFieldType" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>xs:string</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>xs:string</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>xs:string</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>xs:boolean</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>xs:int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>xs:integer</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>xs:int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>xs:int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>xs:string</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>xs:date</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>xs:integer</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>xs:decimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>xs:decimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>xs:float</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:text>xs:string</xsl:text>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

	<xsl:template name="getSqlParam">
		<xsl:param name="pFieldType" />
		<xsl:call-template name="getSqlParamType">
			<xsl:with-param name="pFieldType" select="$pFieldType" />
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="( $pFieldType = 'Varchar' ) or ( $pFieldType = 'Char' )">
				<xsl:text>( </xsl:text>
				<xsl:value-of select="@size" />
				<xsl:text> )</xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
   <xsl:template name="getSqlParamType">
      <xsl:param name="pFieldType" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>VARCHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>CHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>UNIQUEIDENTIFIER</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>BIT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>INT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>BIGINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>TINYINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>SMALLINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>TEXT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>DATETIME</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>INT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>DECIMAL</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>MONEY</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>FLOAT</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldType" />
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

	<xsl:template name="getSqlParamSize">
		<xsl:param name="pSourceField" />
		<xsl:variable name="PARAM_TYPE" select="$pSourceField/@type" />
		<xsl:choose>
			<xsl:when test="$pSourceField/@size &gt; 0">
				<xsl:value-of select="$pSourceField/@size" />
				<xsl:if test="$pSourceField/@scale &gt; 0">
					<xsl:text>, </xsl:text>
					<xsl:value-of select="$pSourceField/@scale" />
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$pSourceField/@size" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getBCPLength">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
         <xsl:when test="$vType = 'Uniqueidentifier'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bit'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Tinyint'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Smallint'">
            <xsl:text>2</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Int'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Identity'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bigint'">
            <xsl:text>8</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Decimal'">
            <xsl:text>10</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Text'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'DateTime'">
            <xsl:text>8</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pSourceField/@size" />
         </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getBCPPrefixLength">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
         <xsl:when test="$vType = 'Uniqueidentifier'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bit'">
				<xsl:choose>
					<xsl:when test="$pSourceField/@required">
						<xsl:text>0</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>1</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
         </xsl:when>
         <xsl:when test="$vType = 'Tinyint'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Smallint'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Int'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Identity'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bigint'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Decimal'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Text'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Varchar'">
            <xsl:text>2</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'DateTime'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:text>0</xsl:text>
         </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getBCPStorageType">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
         <xsl:when test="$vType = 'Uniqueidentifier'">
            <xsl:text>SQLUNIQUEID</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bit'">
				<xsl:text>SQLBIT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Tinyint'">
            <xsl:text>SQLTINYINT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Smallint'">
            <xsl:text>SQLSMALLINT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Int'">
            <xsl:text>SQLINT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Identity'">
            <xsl:text>SQLINT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bigint'">
            <xsl:text>SQLBIGINT</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Decimal'">
            <xsl:text>SQLDECIMAL</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Text'">
            <xsl:text>SQLCHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Varchar'">
            <xsl:text>SQLCHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'DateTime'">
            <xsl:text>SQLDATETIME</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:text>SQLCHAR</xsl:text>
         </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getBCPCollation">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
			<xsl:when test="$vType = 'Varchar'">
				<xsl:text>SQL_Latin1_General_CP1_CI_AS</xsl:text>
			</xsl:when>
			<xsl:when test="$vType = 'Text'">
				<xsl:text>SQL_Latin1_General_CP1_CI_AS</xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getInvernioLength">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
         <xsl:when test="$vType = 'Uniqueidentifier'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bit'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Int'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Text'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'DateTime'">
            <xsl:text>8</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pSourceField/@size" />
         </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getInvernioPrecision">
		<xsl:param name="pSourceField" />
		<xsl:variable name="vType" select="$pSourceField/@type" />
		<xsl:choose>
         <xsl:when test="$vType = 'Uniqueidentifier'">
            <xsl:text>0</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Bit'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Int'">
            <xsl:text>10</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Text'">
            <xsl:text>2147483647</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'DateTime'">
            <xsl:text>23</xsl:text>
         </xsl:when>
         <xsl:when test="$vType = 'Varchar'">
				<xsl:value-of select="@size" />
         </xsl:when>
         <xsl:when test="$vType = 'Char'">
				<xsl:value-of select="@size" />
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pSourceField/@scale" />
         </xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
   <xsl:template name="getSqlTableType">
      <xsl:param name="pFieldType" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>INT IDENTITY( 1, 1 )</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>VARCHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>CHAR</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>UNIQUEIDENTIFIER</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>BIT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>INT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>BIGINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>TINYINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>SMALLINT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>TEXT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>DATETIME</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>INT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>DECIMAL</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>MONEY</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>FLOAT</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>DECIMAL</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>MONEY</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>FLOAT</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldType" />
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   <xsl:template name="getNETType">
      <xsl:param name="pFieldType" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>System.String</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>System.String</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>System.Guid</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>System.Boolean</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>System.Int32</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>System.Int64</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>System.Int16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>System.Int16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>System.String</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>System.DateTime</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>System.Int32</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>System.Decimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>System.Decimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>System.Decimal</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldType" />
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   <xsl:template name="getNETParamType">
      <xsl:param name="pFieldType" />
      <xsl:param name="pRequired" />
		<xsl:choose>
			<xsl:when test="$pRequired = 'True'">
				<xsl:call-template name="getNETType">
					<xsl:with-param name="pFieldType" select="$pFieldType" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$pFieldType = 'Varchar'">
						<xsl:text>string</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Char'">
						<xsl:text>string</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Uniqueidentifier'">
						<xsl:text>Guid</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Int'">
						<xsl:text>Nullable&lt;Int32&gt;</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Bigint'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Smallint'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Tinyint'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Bit'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Text'">
						<xsl:text>string</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'DateTime'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Identity'">
						<xsl:text>Nullable&lt;Int32&gt;</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Decimal'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Money'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:when test="$pFieldType = 'Float'">
						<xsl:text>object</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$pFieldType" />
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
   </xsl:template>
   
   <xsl:template name="getDataUtilityFunction">
		<xsl:param name="pFieldType" />
		<xsl:param name="pSourceObject" />
		<xsl:param name="pTargetObject" />
		<xsl:param name="pDefault" />
		<xsl:param name="pRequired" />
		<xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>DataUtility.GetString</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>DataUtility.GetString</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>DataUtility.GetGuid</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>DataUtility.GetBool</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>DataUtility.GetInt32</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>DataUtility.GetInt64</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>DataUtility.GetInt16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>DataUtility.GetInt16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>DataUtility.GetString</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>DataUtility.GetDateTime</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>DataUtility.GetInt32</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>DataUtility.GetDecimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>DataUtility.GetDecimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>DataUtility.GetDecimal</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldType" />
         </xsl:otherwise>
      </xsl:choose>
      <xsl:text>( </xsl:text>
      <xsl:value-of select="$pSourceObject" />
      <xsl:text>, "</xsl:text>
      <xsl:value-of select="$pTargetObject" />
      <xsl:text>"</xsl:text>
		<xsl:if test="$pRequired = 'True'">
			<xsl:choose>
				<xsl:when test="$pFieldType = 'Bit'">
					<xsl:text>, </xsl:text>
					<xsl:value-of select="$pDefault" />
				</xsl:when>
				<xsl:when test="$pFieldType = 'Int'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Bigint'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Smallint'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Tinyint'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'DateTime'">
					<xsl:text>, DateTime.Now</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Identity'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Decimal'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Money'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
				<xsl:when test="$pFieldType = 'Float'">
					<xsl:text>, 0</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
      <xsl:text> )</xsl:text>
   </xsl:template>

   <xsl:template name="getSqlDbType">
      <xsl:param name="pFieldType" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>SqlDbType.VarChar</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>SqlDbType.Char</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>SqlDbType.UniqueIdentifier</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>SqlDbType.Bit</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>SqlDbType.Int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>SqlDbType.Int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>SqlDbType.Int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>SqlDbType.Int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>SqlDbType.Text</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>SqlDbType.DateTime</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>SqlDbType.Int</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>SqlDbType.Decimal</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>SqlDbType.Money</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>SqlDbType.Float</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldType" />
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   <xsl:template name="getSqlDbSize">
      <xsl:param name="pFieldType" />
      <xsl:param name="pFieldSize" />
      <xsl:choose>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>16</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>1</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>8</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>4</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$pFieldSize" />
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   
   <xsl:template name="getNETEmptyValue">
      <xsl:param name="pFieldType" />
		<xsl:choose>
         <xsl:when test="$pFieldType = 'Varchar'">
            <xsl:text>System.String.Empty</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Char'">
            <xsl:text>System.String.Empty</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Uniqueidentifier'">
            <xsl:text>System.Guid.Empty</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bit'">
            <xsl:text>false</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Int'">
            <xsl:text>System.Int32.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Bigint'">
            <xsl:text>System.Int64.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Smallint'">
            <xsl:text>System.Int16.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Tinyint'">
            <xsl:text>System.Int16.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Text'">
            <xsl:text>System.String.Empty</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'DateTime'">
            <xsl:text>System.DateTime.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Identity'">
            <xsl:text>System.Int32.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Decimal'">
            <xsl:text>System.Decimal.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Money'">
            <xsl:text>System.Decimal.MinValue</xsl:text>
         </xsl:when>
         <xsl:when test="$pFieldType = 'Float'">
            <xsl:text>System.Decimal.MinValue</xsl:text>
         </xsl:when>
			<xsl:otherwise>
				<xsl:text>null</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
   </xsl:template>
   
</xsl:stylesheet>